//
//  Login.m
//  ArtCircle
//
//  Created by sunbin on 2017/5/18.
//  Copyright © 2017年 Quanli. All rights reserved.
//

#import "Login.h"
#import "QuickLogin.h"

@interface Login ()<AccountBackgroundDelegate>
@end

@implementation Login





- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.title = @"快捷登录";

    WEAKSELF;
    self.contentView.inputBoxView.one.nextStepHandler = ^(NSString *account, NSInteger make) {
        make == 2?[weakSelf loginWidthAccount:account]:[weakSelf presentViewController:@[@"QuickRegistration" ,@"PasswordLogin"][make] animationType:WXSTransitionAnimationTypeSysFade isSysBackAnimation:YES];
    };


}


#pragma make 验证码登录
- (void)loginWidthAccount:(NSString *)account {

    WEAKSELF;
    [weakSelf.navigationController.view showLoading:@"正在登录"];
    
    NSDictionary * params= @{@"phone":account};

    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.25 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        
         [weakSelf.navigationController.view hideHUD];
        
        [[AccountManage sharedAccountManage] request:Request apiTy:API_CodeLogin params:params success:^(NSDictionary *results, NSString *successMsg) {
            
            //成功 跳转验证 带参数
            QuickLogin *quickLogin = [[QuickLogin alloc] init];
            
            quickLogin.params = params;
            quickLogin.msg    = successMsg;

            [weakSelf.navigationController pushViewController:quickLogin animated:nil];
            
        } failed:^(WrapperEnumError errorty, NSString *msg) {
            errorty == Failure? [CommonUtils showAlertWithTaget:weakSelf andMsg:msg]:[weakSelf.navigationController.view showError:msg];
        }];
    });
}






- (BOOL)isShowAuthorizedLoginView {
    return YES;
}

- (BOOL)isShowAccountHeaderView {
    return YES;
}

- (InputBoxType)getInputBoxType {
    return InputBoxTypeOne;
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    
}


@end
